﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel.DomainServices.Server;
using System.ComponentModel.DataAnnotations;

namespace NetBay.Core.BusinessEntities.Historic
{
    [DataContract]
    public class HistoricInformation : ReturnObject
    {
        private IEnumerable<HistoricIndex> _indexes = new List<HistoricIndex>();

        [DataMember]
        public long Identifier { get; set; }

        [DataMember]
        public DateTime ActionDate { get; set; }

        [DataMember]
        public TimeSpan ActionTime { get; set; }

        [DataMember]
        public string OrganizationName { get; set; }

        [DataMember]
        public string FoldertypeName { get; set; }

        [DataMember]
        public int DocumentsCountInFolder { get; set; }

        [Association("FK_Indexes", "Key", "ForeignKey")]
        [Include]
        [DataMember]
        public IEnumerable<HistoricIndex> Indexes
        {
            get { return _indexes; }
            set
            {
                if (value != null)
                {
                    _indexes = value;
                    _indexes.ToList().ForEach(i => i.Key = Guid.NewGuid());
                    ItemEntity.SetForeignKey(_indexes, Key);
                }
            }
        }

        [DataMember]
        public int FoldersCountResultInSearch { get; set; }

        [DataMember]
        public int IndexedDocumentsCount { get; set; }


        [DataMember]
        public int FolderTypeId { get; set; }

        [DataMember]
        public int OrganizationId { get; set; }

        [DataMember]
        public int FolderId { get; set; }

        [DataMember]
        public string FolderIdDoc { get; set; }

        [DataMember]
        public bool IsSaved { get; set; }

        [DataMember]
        public string ItemName { get; set; }
    }
}
